package com.hgw.Demo09_StrategyPattern.StrategyPattern;

/**
 * Data time:2021/12/20 20:10
 * StudentID:2019112118
 * Author:hgw
 * Description: 环境类
 */
public class Context {
    private AbstractStrategy strategy;      //维持一个对抽象策略类的引用

    public void setStrategy(AbstractStrategy strategy) {
        this.strategy = strategy;
    }

    // 调用策略类中的算法
    public void algorithm() {
        strategy.algorithm();
    }
}
